
extends Area2D

var controller
var text:Array[String] = ["Hi! I'm a forgotten cutscene.", "Please fix me."]
var check = null
var cutscene = true
var do_text = true

func _ready():
	var test = get_node("/root/Progress").checks
	if (check == null or (check != null and not test[check])):		
		controller = get_node("/root/Controller")
		connect("body_entered", _on_Area2D_body_enter)

func _on_Area2D_body_enter( body ):
	if (body is Player):
		show()
		if (cutscene):
			controller.begin_cutscene()
		want_save()
		begin_cutscene()
		disconnect("body_entered", _on_Area2D_body_enter)

func begin_cutscene():
	doText()

func want_save():
	doSave()

func doText():
	if (do_text):
		controller.show_text(text)

func doSave():
	var test = get_node("/root/Progress").checks
	if (check != null):
		test[check] = true
